<<<<<<< HEAD
<template>
    <div>
        <div>
            <van-tabs v-model="active">
                <van-tab title="未维修">
                    <div class="wuyeRepaire">
                        <div v-for="data in unFinishedData" class="repaire-list" :key="data.repaire_id">
                            <div class="repaire-list-head">
                                <div class="repaire-list-head1">
                                    <span>订单编号:{{data.repaire_id}}</span>
                                </div>
                                <div>
                                    <span>业主昵称:{{data.u_id}}</span>
                                </div>
                                <van-tag round
                                         :type="data.repaire_status == 0 ? 'danger' : (data.repaire_status == 1 ? 'success' : 'warning')">
                                    {{data.repaire_status == 0 ? '未维修' : (data.repaire_status == 1 ? '已维修' : '正在维修')}}
                                </van-tag>
                            </div>
                            <div class="repaire-list-body">
                                <div class="repaire-list-body1">
                                    <div>
                                        <span>地点:{{data.addRess}}</span>
                                    </div>
                                    <span>是否审核:{{data.is_audit == 0 ? '未审核' :'已审核'}}</span>
                                    <div>
                                        <span>故障原因:{{data.repaire_desc}}</span>
                                    </div>
                                    <div>
                                        <span>维修类别:{{data.type_name}}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="repaire-list-options">
                                <van-button type="primary" :disabled="data.is_audit == 1"
                                            @click="changeIsAudit(data.repaire_id)" size="mini">
                                    {{data.is_audit == 0 ? '审核' : '已审核'}}
                                </van-button>
                                </van-button>
                                <van-button type="primary" :disabled="data.is_audit == 0"
                                            @click="sendRepaire(data.repaire_id)" size="mini">{{isPaidan == true
                                    ?
                                    '已派单':'派单'}}
                                </van-button>
                            </div>
                            <van-divider
                                    :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }"
                            >
                            </van-divider>
                        </div>
                    </div>
                </van-tab>
                <van-tab title="正在维修中">
                    <div class="wuyeRepaire">
                        <div v-for="data in doingData" class="repaire-list" :key="data.repaire_id">
                            <div class="repaire-list-head">
                                <div class="repaire-list-head1">
                                    <span>订单编号:{{data.repaire_id}}</span>
                                </div>
                                <div>
                                    <span>业主昵称:{{data.u_id}}</span>
                                </div>
                                <van-tag round
                                         type="warning">
                                    正在维修
                                </van-tag>
                            </div>
                            <div class="repaire-list-body">
                                <div class="repaire-list-body1">
                                    <div>
                                        <span>地点:{{data.addRess}}</span>
                                    </div>
                                    <span>是否审核:{{data.is_audit == 0 ? '未审核' :'已审核'}}</span>
                                    <div>
                                        <span>故障原因:{{data.repaire_desc}}</span>
                                    </div>
                                    <div>
                                        <span>维修类别:{{data.type_name}}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="repaire-list-options">
                                <van-button type="primary" :disabled="true"
                                            @click="sendRepaire(data.repaire_id)" size="mini">{{data.repaireman != null
                                    ?
                                    '已派单':'派单'}}
                                </van-button>
                            </div>
                            <van-divider
                                    :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }"
                            >
                            </van-divider>
                        </div>
                    </div>
                </van-tab>
                <van-tab title="已维修">
                    <div class="wuyeRepaire">
                        <div v-for="data in finishedData" class="repaire-list" :key="data.repaire_id">
                            <div class="repaire-list-head">
                                <div class="repaire-list-head1">
                                    <span>订单编号:{{data.repaire_id}}</span>
                                </div>
                                <div>
                                    <span>业主昵称:{{data.u_id}}</span>
                                </div>
                                <van-tag round
                                         :type="data.repaire_status == 0 ? 'danger' : (data.repaire_status == 1 ? 'success' : 'warning')">
                                    {{data.repaire_status == 0 ? '未维修' : (data.repaire_status == 1 ? '已维修' : '正在维修')}}
                                </van-tag>
                            </div>
                            <div class="repaire-list-body">
                                <div class="repaire-list-body1">
                                    <div>
                                        <span>地点:{{data.addRess}}</span>
                                    </div>
                                    <span>是否审核:{{data.is_audit == 0 ? '未审核' :'已审核'}}</span>
                                    <div>
                                        <span>故障原因:{{data.repaire_desc}}</span>
                                    </div>
                                    <div>
                                        <span>维修类别:{{data.type_name}}</span>
                                    </div>
                                </div>
                            </div>
                            <div class="repaire-list-options">
                                <van-button type="primary" :disabled="true"
                                            @click="sendRepaire(data.repaire_id)" size="mini">{{data.repaireman != null
                                    ?
                                    '已派单':'派单'}}
                                </van-button>
                            </div>
                            <van-divider
                                    :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }"
                            >
                            </van-divider>
                        </div>
                    </div>
                </van-tab>
            </van-tabs>
            <van-notify v-model="isAudit" type="primary">
                <van-icon name="passed" style="margin-right: 4px;"/>
                <span>审核成功</span>
            </van-notify>
            <!--<van-button type="primary" text="组件调用" @click="showNotify"/>-->
            <van-notify v-model="show1" type="success">
                <van-icon name="success" style="margin-right: 4px;"/>
                <span>派单成功</span>
            </van-notify>
            <div>
                <van-dialog v-model="show" title="标题" @confirm="sendMessage" show-cancel-button>
                    <div>
                        <van-radio-group v-for="man in repaireman" @change="changeRadio" v-model="radio">
                            <van-radio :name="man">
                                {{man}}
                                <template #icon="props">
                                    <img class="img-icon" :src="props.checked ? activeIcon : inactiveIcon"/>
                                </template>
                            </van-radio>
                        </van-radio-group>
                    </div>
                </van-dialog>
            </div>
        </div>
    </div>
</template>

<script>
    //这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
    //例如：import 《组件名称》 from '《组件路径》';
    import {Indicator} from 'mint-ui';
    import {Toast} from 'vant';
    import {Notify} from 'vant';

    export default {
        //import引入的组件需要注入到对象中才能使用
        components: {},
        data() {
            //这里存放数据
            return {
                activeNames: ["1"],
                repaire_data: [],
                finishedData: [],
                unFinishedData: [],
                doingData: [],
                show: false,
                show1: false,
                isAudit: false,
                repaireman: [],
                load: false,
                radio: '',
                repaire_id: 0,
                activeIcon: 'https://img.yzcdn.cn/vant/user-active.png',
                inactiveIcon: 'https://img.yzcdn.cn/vant/user-inactive.png',
            };
        },
        //监听属性 类似于data概念
        computed: {},
        //监控data中的数据变化
        watch: {},
        //是否字段
        isPaidan:false,
        //方法集合
        methods: {
            getDataList() {
                //    获取维修报单
                // axios.get("safty/repaire/list")
                axios.get("safty/repaire/list")
                    .then(res => {
                        if (res.success) {
                            this.repaire_status = res.data;
                            console.log(res.data)
                            for (let i = 0; i < res.data.length; i++) {
                                if (res.data[i].repaire_status == 2) {
                                    this.doingData.push(res.data[i]);
                                } else if (res.data[i].repaire_status == 1) {
                                    this.finishedData.push(res.data[i]);

                                } else if (res.data[i].repaire_status == 0) {
                                    this.unFinishedData.push(res.data[i]);

                                }
                            }
                            console.log(this.unFinishedData);
                        } else {
                            Toast({
                                message: res.message,
                                duration: 1000
                            });
                        }
                    })
                    .catch(err => {

                    })
            },
            //派单
            sendRepaire(id) {
                console.log(id);
                this.repaire_id = id;
                this.isPaidan = true;
                Indicator.open('加载中...');
                setTimeout(() => {
                    Indicator.close();
                    this.getRepaireEm();
                    //开启弹框
                    this.show = true;
                }, 1000);
            },
            //获取维修人员的方法
            getRepaireEm() {
                axios.get("safty/repaire/listRepaireMan")
                    .then(res => {
                        if (res.success) {
                            console.log(res.data);
                            this.repaireman = res.data;
                        }
                    })
                    .catch(err => {

                    })
            },
            changeRadio(value) {
                console.log(value);
                this.radio = value;
            },
            showNotify() {
                this.show1 = true;
                setTimeout(() => {
                    this.show1 = false;
                }, 2000);
            },
            sendMessage() {
                //bug  当未选择时也会关闭弹框
                console.log(this.radio);
                if (this.radio == '') {
                    Toast('请选择维修人员');
                } else {
                    axios.get("safty/repaire/addUserRepaire", {
                        params: {
                            u_id: this.radio,
                            repaire_id: this.repaire_id
                        }
                    })
                        .then(res => {
                            if (res.success) {
                                this.showNotify();
                                console.log(res)
                                this.radio = '';
                                this.repaire_id = 0;
                            } else {
                                Toast({
                                    message: res.message,
                                    duration: 1000
                                });
                            }
                        })
                        .catch(err => {

                        })
                }

            },
            showNotifyIsAduit() {
                this.isAudit = true;
                setTimeout(() => {
                    this.isAudit = false;
                }, 2000);
            },
            changeIsAudit(id) {
                console.log(id)
                this.repaire_id = id;
                axios.put("safty/repaire/passAudit/"+this.repaire_id)
                    .then(res=>{
                        if(res.success){
                            this.showNotifyIsAduit();
                            console.log(res);
                        }
                        setTimeout(()=>{
                            this.$router.go(0);
                        },500)
                    })
                    .catch(err=>{

                    })
            }
        },
        //生命周期 - 创建完成（可以访问当前this实例）
        created() {
        },
        //生命周期 - 挂载完成（可以访问DOM元素）
        mounted() {
            this.getDataList();
        },
        beforeCreate() {
        }, //生命周期 - 创建之前
        beforeMount() {
        }, //生命周期 - 挂载之前
        beforeUpdate() {
        }, //生命周期 - 更新之前
        updated() {
        }, //生命周期 - 更新之后
        beforeDestroy() {
        }, //生命周期 - 销毁之前
        destroyed() {
        }, //生命周期 - 销毁完成
        activated() {
        } //如果页面有keep-alive缓存功能，这个函数会触发
    };
</script>
<style>
    .wuyeRepaire {
        margin-top: 10px;
        margin-bottom: 80px;
    }

    .repaire-list {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 20px;
    }

    .img-icon {
        height: 20px;
    }

    .repaire-list-head {
        width: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .repaire-list-head1 {
        display: block;
        width: 100%;
    }

    .repaire-list-body {
        width: 100%;
        display: flex;
        justify-content: left;
        flex-wrap: wrap;
        flex-direction: row;
        align-items: center;
    }

    .repaire-list-body .repaire-list-body1 {
        /*border: 1px solid red;*/
        width: 100%;
        display: block;
        justify-content: left;
    }
=======

<template>
  <div class>
    <div class="repaire-list">
      <van-collapse v-model="activeNames">
        <van-collapse-item name="1">
          <template #title>
            <div>
              <van-tag round type="danger">未维修</van-tag>维修订单1
            </div>
          </template>
          <div>
            <van-swipe-cell>
              <template #left>
                <van-button square type="primary" text="维修" />
              </template>
              <van-cell :border="false" :title="repaire_data[0].user_name" :value="repaire_data[0].address" />
              <template #right>
                <van-button square type="danger" text="删除" />
                <van-button square type="primary" text="收藏" />
              </template>
            </van-swipe-cell>
          </div>
        </van-collapse-item>
      </van-collapse>
      <van-collapse v-model="activeNames">
        <van-collapse-item name="2">
          <template #title>
            <div>
              <van-tag round type="warning">正在维修</van-tag>维修订单2
            </div>
          </template>
          <div>
            <van-swipe-cell>
              <template #left>
                <van-button square type="primary" text="维修" />
              </template>
              <van-cell :border="false" :title="repaire_data[0].user_name" :value="repaire_data[0].address" />
              <template #right>
                <van-button square type="danger" text="删除" />
                <van-button square type="primary" text="收藏" />
              </template>
            </van-swipe-cell>
          </div>
        </van-collapse-item>
      </van-collapse>
      <van-collapse v-model="activeNames">
        <van-collapse-item name="3">
          <template #title>
            <div>
              <van-tag round type="success">已维修</van-tag>维修订单2
            </div>
          </template>
          <div>
            <van-swipe-cell>
              <template #left>
                <van-button square type="primary" text="维修" @click="select1"/>
              </template>
              <van-cell :border="false" :title="repaire_data[0].user_name" :value="repaire_data[0].address" />
              <template #right>
                <van-button square type="danger" text="删除" @click="delete1"/>
                <van-button square type="primary" text="收藏" />
              </template>
            </van-swipe-cell>
          </div>
        </van-collapse-item>
      </van-collapse>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      activeNames: ["1"],
      repaire_data: [
        {
          user_name: "张三",
          user_phone: "123456789",
          address: "三号楼三单元301室"
        }
      ]
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
      select1(){
          console.log("111");
      },
    delete1(){
        console.log("接单");
    },

  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style>
.repaire-list {
  border: 1px solid red;
}
>>>>>>> 70f7e19d6da4b30f0412d394b1171a015e63af36
</style>